/*
 * @Author: your name
 * @Date: 2021-01-21 22:25:09
 * @LastEditTime: 2021-01-26 00:14:40
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \ad-api\routes\admin\page.js
 */
const express = require('express');
const router = express.Router();
const Result = require('../../models/result.js');
const { getPageListService , addPageService , delPageService} = require('../../service/pageService')
//获取页面列表
router.post('/list', async (req, res, next)=>{
           const { page_id } = req.body
           const {results ,status} = await getPageListService(page_id)
           if(status){
            new Result(results , "查询成功").success(res)
           }else{
            new Result({},'服务器错误,查询失败').fail(res) 
           }
})
//添加页面
router.post('/add_page', async (req, res, next)=>{
  const {results ,status} = await addPageService(req.body)
  if(status){
    new Result(req.body , '添加页面成功').success(res)
  }else{
    new Result({},'添加失败').fail(res)
  }
})
//删除页面
router.post('/del_page', async (req, res, next)=>{
  const {results ,status} = await delPageService(req.body)
  if(status){
    new Result(req.body , '删除页面成功').success(res)
  }else{
    new Result({},'删除失败').fail(res)
  }
})
module.exports = router;